<?php
	include "common.php";
	session_start();
	error_reporting(0);	
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}
	$userLink = $_SESSION['userLink'];
	if($userLink!="ceo.php"){
		echo "Sorry, You have no right to visit this page!!";
		exit;
	}
	$userName = $_SESSION['userFname'];
	$role = $_SESSION['role'];
	$ID = $_SESSION['id'];
	$supervisor = $_SESSION['supervisor'];

	$noticeType =$_POST['noticeType'];
	$noticeDay = $_POST['day'];
	$noticeMonth = $_POST['month'];
	$noticeYear  = $_POST['year'];
	$noticeDay1 = $_POST['day1'];
	$noticeMonth1 = $_POST['month1'];
	$noticeYear1 = $_POST['year1'];
	$noticeFor = $_POST['notice_for'];
	
	$noticeFrom = $noticeYear."-".$noticeMonth."-".$noticeDay;
	$noticeTo = $noticeYear1."-".$noticeMonth1."-".$noticeDay1;
	
	$sqlForSameNotice = "SELECT * FROM notice_board WHERE from_date='$noticeFrom' && to_date='$noticeTo' && description='$noticeFor'";
	$sqlForSameNotice = mysql_query($sqlForSameNotice);
	$checkThisNoticeAllreadyIncluded = mysql_num_rows($sqlForSameNotice);
	
	//*************** Insert into apply_leave table *********************
	if($checkThisNoticeAllreadyIncluded==0){
		 $sql = "INSERT INTO notice_board (from_date,to_date,notice_type,description,status)
				VALUES ('$noticeFrom', '$noticeTo', '$noticeType', '$noticeFor', '1')";				
		 $sqlResult = mysql_query($sql);
		 $collectData = "UPDATE notice_showed SET status=1 WHERE status='0'";
		 $collectDataQuery = mysql_query($collectData);		
	}
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="index.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="show_report.css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title><?php echo "Welcome to ".$userFname." ".$userLname; ?></title>
</head>

<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<div class="new_notification">
        	<img src="images/arrow_up.JPG" /><?php if ($notification >0){?><p>You have<?php echo " ".$notification." ";?>new notification</p><?php }?>
        </div><!--end of new_notification-->
    	<ul>
        	<a href="ceo.php"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="ceo_employee.php"><li><div id="employee"></div><p>employee</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="on_duty.php"><li><div id="onduty"></div><p>on duty</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="ceo_attendance.php"><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="leave.php"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="ceo_notification.php"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="ceo_blackbox.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="#"><li><div id="hrpolicy"></div><p>hr policy</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
    
</div><!-- end of main_div_other-->
<div class="othrpage_1">
    <p>view as: <a href="ceo_notice.php?check=1">Create Notice</a> | <a href="ceo_notice.php?check=2">Check</a> | <a href="ceo_notice.php?check=3">Approve Employees </a>
</div><!-- end of othrpage_1-->
<div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->
    
    <div class="page_content">
    	<br><br>
		<?php
			if($checkThisNoticeAllreadyIncluded==0){
				?>
                <p><b>Your notice will be showed on the notice board.</b></p>
                <?php
			}
			else{
				?>
                <p><b>You already submitted the same notice.</b></p>
                <?php
			}
		?>
        <a href="ceo_notice.php?check=1">Back to create another notice.</a>	
    </div><!-- end of page_content -->
</div><!-- end of main_div-->
</body>
</html>